package com.github.postsanf.yinian.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by Administrator on 2016/8/23.
 */
public class XieView extends View {
    private int lineColor;//横线颜色
    private float lineWidth;//横线宽度
    private Context context;

    public XieView(Context context) {
        super(context);
        //设置默认颜色和横线宽度
        lineColor = Color.parseColor("#ffffff");
        lineWidth = 12f;
    }

    public XieView(Context ctx, AttributeSet attrs) {
        super(ctx, attrs);
    }

    public XieView(Context context, int color, float width) {
        super(context);
        //设置颜色和横线宽度
        this.context = context;
        this.lineColor = color;
        this.lineWidth = width;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        //创建画笔
        Paint mPaint = new Paint();
        mPaint.setStrokeWidth(lineWidth);
        mPaint.setColor(lineColor);
        canvas.drawLine(0,
                0,
                getWidth(),
                getHeight(),
                mPaint);
        super.onDraw(canvas);
    }

    public int getLineColor() {
        return lineColor;
    }

    public void setLineColor(int color) {
        this.lineColor = color;
    }

    public float getLineWidth() {
        return lineWidth;
    }

    public void setLineWidth(float width) {
        this.lineWidth = width;
    }
}
